import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {CudTableService} from '../../../public/serve/cud-table/cud-table.service';
import {Service} from '../../../server/server';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
import {HintsService} from '../../../public/serve/hints/hints.service';
declare var $:any;
@Component({
  selector: 'app-indexing-popover',
  templateUrl: './indexing-popover.component.html',
  styleUrls: ['./indexing-popover.component.css']
})
export class IndexingPopoverComponent implements OnInit {

  public id : any;
  public theme_id : any;
  public indexing_name : any;
  public data_order : any;
  public internalLeftIndexingDeleteEmit: any;
  @Input() internalParam : any;

  constructor(
    private server: Service,
    public request: CudTableService,
    private tableListService: CudTableService,
    private hintsService: HintsService,
    private removeTableService: RemoveTableService,
    private http: HttpClient
  ) { }

  ngOnInit() {
    this.internalLeftIndexingDeleteEmit = this.server.internalLeftIndexingDeleteEmit.subscribe((value: any) => {
      if (value) {
          this.id = value.id;
          this.theme_id = value.theme_id;
          this.indexing_name = value.indexing_name;
          this.data_order = value.data_order;
      }
    });
  }

  ngOnDestroy() {
    this.internalLeftIndexingDeleteEmit ? this.internalLeftIndexingDeleteEmit.unsubscribe() : '';
  }

  /**
     * 删除（弹窗）
     * @param info
     */
    _delete() {
      //还缺少this.id && 
      if(this.theme_id){
        this.server.internalDeleteThemeIdEmit.emit(this.theme_id + ',' + this.data_order);
        //this.removeTableService.keywordRemoveChose(true,this.id,1);//删除右侧列表的主题词
        $("#deletePopover").modal("show");
      }
  }

}
